﻿@using ClassifiedAds.IdentityServer.Models.ApiResourceModels
@model ScopeModel

<div class="row">
    <div class="col-12">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a asp-controller="ApiResource" asp-action="Index">Api Resources</a></li>
                <li class="breadcrumb-item"><a asp-controller="ApiResource" asp-action="Edit" asp-route-id="@Model.ApiResourceId">@Model.ApiResourceName</a></li>
                <li class="breadcrumb-item"><a asp-controller="ApiResource" asp-action="Scopes" asp-route-id="@Model.ApiResourceId">Scopes</a></li>

                @if (Model.Id != 0)
                {
                    <li class="breadcrumb-item active" aria-current="page">@Model.Name</li>
                }
                else
                {
                    <li class="breadcrumb-item active" aria-current="page">Add Scope</li>
                }
            </ol>
        </nav>
    </div>

    <div class="col-12">
        <h2>Scopes</h2>
    </div>
</div>

<form asp-action="EditScope" id="api-scope-form" method="post">

    <div asp-validation-summary="All" class="text-danger"></div>

    <!--Hidden -->
    <input type="hidden" asp-for="Id" />

    <!--Hidden -->
    <input type="hidden" asp-for="ApiResourceId" />

    <div class="card mt-3">
        <h5 class="card-header">Scope</h5>
        <div class="card-body">
            <!--Input - text -->
            <div class="form-group row">
                <label asp-for="Name" class="col-sm-3 col-form-label">
                    @await Html.PartialAsync("_Label", "Name")
                </label>
                <div class="col-sm-9">
                    <input type="text" required class="form-control" asp-for="Name">
                    <span asp-validation-for="Name" class="text-danger"></span>
                </div>
            </div>

            <!--Input - text -->
            <div class="form-group row">
                <label asp-for="DisplayName" class="col-sm-3 col-form-label">
                    @await Html.PartialAsync("_Label", "Display Name")
                </label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" asp-for="DisplayName">
                </div>
            </div>

            <!--Input - text -->
            <div class="form-group row">
                <label asp-for="Description" class="col-sm-3 col-form-label">
                    @await Html.PartialAsync("_Label", "Description")
                </label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" asp-for="Description">
                </div>
            </div>

            <!--Checkbox-->
            <div class="form-group row">
                <label asp-for="Required" class="col-sm-3 col-form-label">
                    @await Html.PartialAsync("_Label", "Required")
                </label>
                <div class="col-sm-9">
                    <toggle-button>
                        <input asp-for="Required" type="checkbox">
                    </toggle-button>
                </div>
            </div>

            <!--Checkbox-->
            <div class="form-group row">
                <label asp-for="Emphasize" class="col-sm-3 col-form-label">
                    @await Html.PartialAsync("_Label", "Emphasize")
                </label>
                <div class="col-sm-9">
                    <toggle-button>
                        <input asp-for="Emphasize" type="checkbox">
                    </toggle-button>
                </div>
            </div>

            <!--Select with tags-->
            <div class="form-group row">
                <label asp-for="UserClaims" class="col-sm-3 col-form-label">
                    @await Html.PartialAsync("_Label", "User Claims")
                </label>
                <div class="col-sm-9">
                    <picker id="UserClaimsItems" multiple-select="true" min-search-text="2"
                            selected-items="@Model.UserClaims?.Select(x=>x.Type)?.ToList()" url="@Url.Action("GetClaims","IdentityResource")?claim"
                            search-input-placeholder="enter"
                            selected-items-title="selected items"
                            search-result-title="search result"
                            suggested-items-title="suggested items"
                            no-item-selected-title="no item selected"
                            show-all-items-title="show all items"
                            item-already-selected-title="item already selected">
                    </picker>
                </div>
            </div>

            <!--Button-->
            <div class="form-group row">
                <label class="col-sm-3 col-form-label">
                </label>
                <div class="col-sm-9">
                    <button type="submit" asp-action="EditScope" id="api-scope-save-button" class="btn btn-primary">Save</button>
                </div>
            </div>
        </div>
    </div>

</form>

@section scripts
	{
    <script>
        $(function () {
            //Disable enter for this form
            FormMvc.disableEnter($('#api-scope-form'));
        });
    </script>
}